home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
amber
/
amber.lha
/
Rpc.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-25
|
3KB
|
115 lines
#ifndef _rpc_obj_h
#define _rpc_obj_h
#define AmberPrognum 0x4000023
#define AmberVersnum 23
#define AmberRPCCheckin 1
#define AmberRPCCheckout 2
#define AmberRPCSegmentAlloc 3
#define AmberRPCSegmentEntry 4
#define AmberRPCSuicide 5
#define AmberRPCDelete 6
#define AmberRPCMoveD 7
#ifndef cc
#include "MoveData.h"
#include "Segment.h"
#include "Thread.h"
#include "Klock.h"
#include <rpc/rpc.h>
#define CALL 1
#define CALLWR 2
#define REPLY 3
typedef int (*CallBack)(XDR *, void *);
typedef struct up{
CallBack inp;
void *in;
int replyid;
Thread *waiter;
} Upcall;
class RpcObj {
int prognum;
int versnum;
int busy;
int numacked; // used on master only
char nodes[64]; // ditto
int masterack; // used on slave only
Upcall registry[64];
Klock reglock;
int ismaster;
unsigned tid;
// Unix socket based junk
int rcv_sock;
char rcv_buf[1<<13];
XDR rcv_xdr;
unsigned readmask;
void masteracked();
void nodeacked(int ); // used on master only
void inithostrecord(struct amberhost *);
int makesock();
int Call(struct amberhost *,int,CallBack,void*);
int CallRepl(struct amberhost *,int,CallBack,void*,
CallBack,void*);
int Reply(struct sockaddr_in *, int, int , CallBack, void *);
void Register(int tid, Thread *, CallBack, void*);
void Unregister(int, Upcall* = 0);
void Block();
void Decode(int);
void Prod(int, XDR *);
Upcall *Locate(int,int);
void Dispatch(int, int, XDR*, struct sockaddr_in* = 0, int = 0);
int Setpos(XDR *, int);
int Getpos(XDR *);
inline unsigned gettid() { return (++tid != 0) ? tid : ++tid ;}
public:
RpcObj();
void Export(int tn,int prog = AmberPrognum, int vers = AmberVersnum);
void ShutDown();
int GetProgNum() { return prognum;}
int GetVersNum() { return versnum;}
int Busy() { return busy;}
void WaitForClientCheckin(int);
void WaitForMasterAck();
int CheckIn(struct amberhost *, int);
int SegmentAlloc(int, int, int, int *, int *);
int GetSegmentEntry(int, int *,SegmentMode *);
int Delete(int, Object*);
int MoveData(int, RPCDatum *, Object*, ArrivalFunc, int*);
void Recv(int);
};
extern int pmap_set(u_long,u_long,u_long,u_short);
extern int pmap_unset(u_long,u_long);
extern u_short pmap_getport(struct sockaddr_in *,u_long, u_long, u_long);
extern int select(int,int*,int*,int*,struct timeval*);
extern int bind(int, struct sockaddr *, int);
extern int recvfrom(int, char *, int, int, struct sockaddr *, int *);
extern int sendto(int, char *, int,int, struct sockaddr *, int);
extern int getsockname(int, struct sockaddr *, int *);
extern int socket(int , int, int);
extern int bzero(char *, int);
extern RpcObj *rpc;
#endif !cc
struct seg_alloc_struct{
int count;
int mode;
int nodenum;
int firstindex;
int status;
};
struct seg_entry_struct{
int index;
int owner;
int mode;
};
#endif _rpc_obj_h